Repository navigation
Stop restarting a ticket whose last 3 runs failed while it is unchanged - #773
Conversation
nambok
left a comment
There was a problem hiding this comment.
nice split, the gate logic itself reads right. ulid ordering in failed_in_a_row matches how latest is picked, the dashboard retry (api::retry_run) never goes through the gate so it can't hit the cap, /coderhelm comments and run_start pass explicit=true and return before decide, and a content change or jira reopen still gets through. clippy -D warnings clean and cargo test -p gateway passes locally on 6b51106.
one real problem, the cap blocks deliberate retries it says it doesn't:
github_webhook.rs line 593: pass is_labeled || is_assigned_to_bot, not just is_labeled
handle_issue_event returns early unless the event is the coderhelm label being added or the bot being assigned (line 537), so every github issue event that reaches the gate is a person doing one of those two things. there's no incidental unchanged event on this path at all. with only is_labeled exempt, the only thing the cap ever blocks on github is a person assigning coderhelm to the issue, which is exactly the explicit retry the pr says stays allowed, and they get no comment, just a log line. simplest fix is passing true here (the cap never applies to github issue events), or is_labeled || is_assigned_to_bot if you want it spelled out. the pr body's "an incidental unchanged event is skipped" for github doesn't match what the handler can receive.
jira_webhook.rs line 618: same thing for jira re-labels / re-assigns
on jira, removing and re-adding the trigger label (or re-assigning to coderhelm) is the same retry gesture you exempted on github, but it comes in as an unchanged issue_updated and gets skipped at the cap. jira_reopened already reads the changelog, so a sibling that's true when a changelog item has field == "labels" and the trigger label is in toString but not fromString (and the same for assignee moving to coderhelm) can feed label_added. that keeps field/status noise capped, which is the point of the pr, while a person's re-label still retries. add a test for it next to the jira_reopened ones.
non-blocking:
- the decide() test sets
label_added: trueby hand, so nothing would catch the github wiring regressing (or the two fixes above). a small pure helper for "is this event a person's retry gesture" per source, with tests, would cover it. - a skip at the cap is silent to the person. if someone does hit it from a field change that's fine, but a one-line ticket comment the first time it trips ("3 runs failed, edit the ticket or hit retry") would save a "why didn't it run" question. fine as a follow-up.
- alerts also pass
false, so a recurring alert with the same title/body stops after 3 failed runs until someone retries from the dashboard. probably what you want (it was burning runs), just worth a line in the pr body since it isn't mentioned. also notetake_daily_slotis spent before the gate skips, pre-existing but now it'll happen more. - the
status != "retried"literal could usecommon::run_status::RETRIED/FAILEDlike the rest of the codebase.
A failed latest run never blocked a ticket event, so every field or status change on a ticket whose runs kept failing started the same failing run again. There was no per-ticket cap. After 3 runs in a row ended failed, an event that leaves the ticket unchanged now starts no further run. The cap counts only runs that ended failed: a run a person retried (status `retried`, whatever it ended as) neither counts nor ends the streak. Changing the ticket, reopening it, or a person's Retry or command still starts a run; explicit triggers never reach the cap. Split out of #706 at the reviewer's request.
6b51106 to
79f8bf6
Compare
|
Thanks. Point by point:
|
…he issue's repo and the retry gesture
|
Merged |
Split out of #706 at the reviewer's request: this cap was part of that pull request and is now its own change.
A failed latest run never blocked a ticket event, so every field or status change on a ticket whose runs kept failing started the same failing run again. There was no per-ticket cap on these restarts.
What changes
After 3 runs in a row on a ticket ended failed, an event that leaves the ticket unchanged starts no further run (
trigger_gate::MAX_FAILED_RUNS_IN_A_ROW).failed. A run a person retried (statusretried, whatever it ended as) neither counts nor ends the streak, so runs that stopped to ask a question and were retried don't add up to the cap./coderhelmcommand, and a retry gesture on the ticket all still start a run.coderhelmlabel, or assigning the issue to CoderHelm;github_retry_gesture).jira_retry_gesture). Other field and status changes stay capped, which is what the cap is for.Worth knowing:
take_daily_slotis spent before the gate decides, so a capped alert still uses its daily slot. That was already the case for other gate skips; with the cap it happens more often.Evidence
cargo fmt --checkclean,cargo clippy -p gateway --all-targets -- -D warningsclean, andcargo test -p gatewaypassed, including the cap tests (restarts stop on an unchanged ticket, status moves To Do -> In Progress and Done -> open included, while new content or a retry gesture still start one; failures in a row are counted from the newest run with retried runs passed over) and the retry-gesture helpers for GitHub (label add, bot assign) and Jira (trigger label re-added, re-assigned to CoderHelm; a field or status change isn't one).The no-mistakes test step drove the gate live against a local DynamoDB emulator (19 scenarios), including the status-move case this change closes. Not driven against the hosted product: a ticket whose last 3 runs failed and then gets a field or status change starts no run; an edit or a retry gesture (label or assignee on GitHub or Jira) still starts one.
Follow-up: a one-line ticket comment the first time the cap skips an event ("the last 3 runs failed; edit the ticket or press Retry"), so a person isn't left wondering why nothing ran.